#include <bits/stdc++.h>
using namespace std;

const int N = 1000;
int n, a[N], b[N], cnt;

void dfs(int x, int c, int re){
    b[x] = re;
    if (x > n){ cout << c << " " ; return ;}
    for (int i = x-1; i > 0; i--) {
        if (b[i] == b[x]) {
            if (a[i] == a[x]){
                dfs(x+1, c+a[i], 1);
                dfs(x+1, c+a[i], 2);
            } else {
                dfs(x+1, c, 1);
                dfs(x+1, c, 2);
            }
            break;
        }
    }
    return ;
}

int main(){
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int T;
    cin >> T;
    while (T--){
        cnt = 0;
        cin >> n;
        for (int i = 1; i <= n; i++) cin >> a[i];
        dfs(1, 0, 1);
        dfs(1, 0, 2);
        cout << cnt;
    }
    return 0;
}
